<template>
  <div
    class="LoginRegistered"
    @click.stop="none"
    ref="LoginRegistered"
    v-if="login"
  >
    <!-- 选择登录方式 -->
      <transition>
      <div class="login" v-show="edit == 0 ? 1 : 0">
        <h2>登录</h2>
        <div class="account" @click="edit = 1">账号登录</div>
        <div class="captcha" @click="edit = 3">动态验证码登录</div>
        <div class="enroll">没有账号？<span @click="edit = 4">注册</span></div>
      </div>
    </transition>
   

    <!-- 账号密码登录 -->
   <transition >
      <div class="account_login" v-show="edit == 1 ? 1 : 0">
        <h2>账号登录</h2>
        <div class="uname"><input type="text" placeholder="手机号码" v-model="Newusername" /></div>
        <div class="pass"><input type="password" placeholder="密码" v-model="Newpassword" /></div>
        <div class="forget">忘记密码？</div>
        <div class="account" @click="setLogin">登录</div>
        <div class="other" @click="edit = 0"><span>使用其他方式登录</span></div>
        <div class="captcha" @click="edit = 3">动态验证码登录</div>
        <div class="enroll">没有账号？<span @click="edit = 4">注册</span></div>
      </div>
    </transition>

    <!-- 动态验证码登录 -->
    <transition>
      <div class="captcha_login" v-show="edit == 3 ? 1 : 0">
        <h2>动态验证码登录</h2>
        <div class="uname"><input type="text" placeholder="手机号码" /></div>
        <div class="uname yzmimg">
          <input type="text" placeholder="图形验证码" />
          <img src="../assets/img/yzm.png" alt="" />
        </div>
        <div class="uname yzm">
          <input type="text" placeholder="验证码" />
          <div class="code">发送验证码</div>
        </div>
        <div class="account">登录</div>
        <div class="other" @click="edit = 1"><span>使用其他方式登录</span></div>
        <div class="captcha" @click="edit = 1">密码登录</div>
        <div class="enroll">没有账号？<span @click="edit = 4">注册</span></div>
      </div>
    </transition>

    <!-- 注册 -->
    <transition>
      <div class=" enroll_login" v-show="edit == 4 ? 1 : 0">
        <div class="captcha_login" >
          <h2>动态验证码登录</h2>
          <div class="uname"><input type="text" placeholder="手机号码" /></div>
          <div class="uname yzmimg">
            <input type="text" placeholder="图形验证码" />
            <img src="../assets/img/yzm.png" alt="" />
          </div>
          <div class="uname yzm">
            <input type="text" placeholder="验证码" />
            <div class="code">发送验证码</div>
          </div>
          <div class="pass">
            <input type="password" placeholder="八位以上带数字和字母密码" />
          </div>
          <div class="pass">
            <input type="password" placeholder="确认密码" />
          </div>
          <div class="account">注册</div>
          <div class="captcha">
            已有账号？<span @click="edit = 0">登录</span>
          </div>
          <div class="provisions">
            <input type="checkbox" >
            <span>注册即代表我同意</span>
            <a href="#">《服务条款和隐私政策》</a>
          </div>
        </div>
      </div>
    </transition>
  </div>
</template>

<script>
export default {
  props: ["login"],
  data() {
    return {
      edit: 0,
      Newusername:'',
      Newpassword:null,
      img_yzm:45196,
      yzm:"",
    };
  },
  methods: {
    setLogin(){
      this.$emit("set-login",{Newname:this.Newusername,Newpassword:this.Newpassword})
    },

    registered(){
      this.$emit("registered",{Newname:this.Newusername,Newpassword:this.Newpassword})
    },
    none(e) {
      let attr = e.target.classList[0];
      let attr2 = this.$refs.LoginRegistered._prevClass;
      if (attr == attr2) {
        this.$emit("none");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.v-enter-active {
  transition: 0.2s linear;
}
.v-enter {
  transform: translateY(100%);
  opacity: 1;
}
.v-leave-to {
  transform: translateY(100%);
  opacity: 0;
}

.LoginRegistered {
  z-index: 1;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background-color: rgba($color: #000000, $alpha: 0.4);
  font-size: 16px;

  .login,
  .account_login,
  .captcha_login {
    z-index: 9;
    border-radius: 6px;
    background-color: #fff;
    margin: 186px 19px 0 19px;

    .enroll {
      font-size: 14px;
      height: 68px;
      line-height: 68px;
      color: #e2e4e8;
      padding-left: 35px;
      span {
        color: #9cdbd3;
      }
    }
    .captcha {
      height: 72px;
      line-height: 72px;
      text-align: center;
      color: #80d7d1;
    }
    .account {
      margin-top: 33px;
      margin-right: 20px;
      margin-left: 20px;
      border-radius: 6px;
      height: 44px;
      text-align: center;
      color: #fff;
      background-color: #80d7d1;
      line-height: 44px;
    }
    h2 {
      text-align: center;
      font-size: 16px;
      color: #333;
      font-weight: bold;
      line-height: 82px;
      height: 82px;
    }
  }
  .account_login,
  .captcha_login {
    .uname {
      margin-top: 5.5px;
    }
    .uname,
    .pass {
      height: 51px;
      padding: 0 20px;
      line-height: 51px;

      input {
        border: none;
        height: 27px;
        line-height: 27px;
        padding: 0;
        font-size: 16px;
        border-bottom: solid 1px #f5f5f5;
        width: 100%;
      }
    }
    margin-top: 55px;
    h2 {
      height: 49px;
    }
    .forget {
      font-size: 13px;
      color: #e0e0e0;
      text-align: right;
      margin-top: 8px;
      margin-bottom: 84px;
      padding-right: 20px;
    }
    .other {
      font-size: 14px;
      color: #f5f6f6;
      text-align: center;
      margin: 0 20px;
      position: relative;
      margin-top: 20px;
      border-top: 1px solid #f0efef;
      span {
        position: absolute;
        top: -10px;
        background-color: #fff;
        padding: 0 3px;
        z-index: 3;
        left: 50%;
        transform: translateX(-50%);
      }
    }
    .enroll {
      margin-top: 30px;
    }
  }
  .captcha_login {
    .yzmimg {
      display: flex;
      input {
        width: 100px;
        flex: 1;
      }
      img {
        width: 100px;
        height: 32px;
        margin-left: 44px;
        background-color: #f5f5f5;
      }
    }
    .yzm {
      display: flex;

      input {
        width: 100px;
        flex: 1;
      }
      .code {
        width: 100px;
        height: 28px;
        border: 1px solid #fd6003;
        border-radius: 7px;
        font-size: 16px;
        text-align: center;
        line-height: 28px;
        color: #fd6003;
        margin-left: 44px;
      }
    }
  }
  .enroll_login {
   
      .provisions{
        font-size: 12px;
        padding: 26px 0;
        justify-content: center;
        display: flex;
        align-items: center;
        input{
          margin-right: 10px;
          width: 10px;
          height: 10px;
          color: #FF5341;
          
        }
        span{
          color: #e0e0e0;
        }
        a{
          color: #333;
        }
      }
    .captcha {
      color: #e6e6e6;
      span {
        color: #80d7d1;
      }
    
    }
  }
}
</style>